package com.cloudkinto.service.platform;

import com.cloudkinto.dto.platform.order.PlatOrderPageRes;
import com.cloudkinto.entity.PlatformOrderDo;
import com.baomidou.mybatisplus.extension.service.IService;

import com.cloudkinto.common.web.PageResult;
import com.cloudkinto.common.web.SingleResult;
import com.cloudkinto.entity.PlatformOrderProductDo;
import com.cloudkinto.service.consumer.vo.order.PlatOrderCancelConsumerReq;
import com.cloudkinto.service.consumer.vo.order.PlatOrderSendConsumerReq;
import com.cloudkinto.service.platform.qoo10.vo.PlatformOrderUpdateReq;
import com.cloudkinto.service.platform.vo.PlatformOrderSetPushStoreReq;
import com.cloudkinto.service.platform.vo.order.MakeShipReq;
import com.cloudkinto.service.platform.vo.order.UpdateToFinishErrorRes;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 平台订单 service接口
 * </p>
 *
 * @author hua
 * @since 2024-12-25
 */
public interface PlatformOrderService extends IService<PlatformOrderDo> {
    void resetStockToPlatformRecord();

    Integer getLastRecordedInventory(String stockRedisKey, String sku);

    void setPushStoreList(PlatformOrderSetPushStoreReq req, Long companyId);

    void resetRedisSyncTime(Boolean amazonFlag);

    List<Long> getAutoCheckStoreList(Long companyId);

//    void updateMarkStatusByNo(List<String> platOrderNo, Integer markShipmentStatus, String failReason);


    /**
     * @param markShipmentStatus * 标发状态 0无 1标发中 2标发失败 3标发成功 4不标发 5待标发
     */
    void updateMarkStatus(List<Long> ids, Integer markShipmentStatus, String failReason);

    void updateMarkStatusForFinish(List<Long> ids, Integer markShipmentStatus, String failReason, String platformCode);

    Object update(Object updateVo, Long userId);

    int delete(Long id, Long userId);

    Object detail(Long id, Long companyId);

    void updatePlatformOrder(PlatformOrderUpdateReq req, Long userId, Long companyId);

    SingleResult pageInit(Long companyId, Long tenantId);

    List<PlatOrderPageRes> getList(Map<String, Object> map);

    PageResult<PlatOrderPageRes> getListPage(Map<String, Object> map);

    PageResult getListPageMailSendStatus(Map<String, Object> map);

    Map<String, Object> statusStatistics(Map<String, Object> map);

    void updateToDeal(MakeShipReq req, Long userId, Long companyId);

    /**
     * 标记为已发货，手动标记的 标发状态为不标发
     */
    List<UpdateToFinishErrorRes> updateToFinish(MakeShipReq req, Long userId, Long companyId, Long tenantId);

    /**
     * 平台订单页面客户手动取消
     */
    void updateToCancel(MakeShipReq req, Long userId, Long companyId);


    /**
     * 匹配本地sku和映射关系
     */
    void matchSystemSku(List<PlatformOrderProductDo> platItems, Long storeId, Long companyId, Long tenantId);

    /**
     * 是否审核成功就自动提交仓库
     */
    Integer ableAutoASubmit(Integer autoSubmit, Long company);


    void autoCheck(String autoType);

    /**
     * 审核
     */
    void check(Map<String, Object> map, Long userId, Long companyId, Long tenantId);

    /**
     * 分配仓库&物流渠道
     */
    void distributeWh(Map<String, Object> map, Long userId, Long companyId, Long tenantId);


    void autoMarkShip();

    /**
     * 标发
     */
    void markShip(Map<String, Object> map, String type, Long userId, Long companyId, Long tenantId);

    /**
     * 一件代发出库 根据平台订单号取消
     */
    void cancel(PlatOrderCancelConsumerReq req);

    void updateWhIdFromOut(List<String> platformOrderNos, Long whId, Long channelId, Long userId, Long companyId);

    /**
     * 根据平台订单号发货
     */
    void send(PlatOrderSendConsumerReq req);

    void importTrackNo(MultipartFile file, Long userId, Long companyId, Long tenantId);

    void getPlatformOrderTrackTemplate(HttpServletResponse response, Long tenantId) throws IOException;

    void export(Map<String, Object> map, HttpServletResponse response);

    void cancelMatchSysProduct(List<Long> ids, Long userId, Long companyId);
}
